-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assemble-repository: Prevent sources from being included inadvertently #3635
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It goes in the right direction but basically I would
- check here if this is a requirement for a source bundle
- Construct a context IU with
org.eclipse.update.install.sources=true/false
- then check if they match in
isApplicable(IInstallableUnit iu, IRequirement req)
that way the requirements will just be filtered out.
@@ -118,6 +119,10 @@ protected Slicer createSlicer(SlicingOptions options) throws ProvisionException | |||
boolean considerOnlyStrictDependency = options.considerStrictDependencyOnly(); | |||
return new PermissiveSlicer(repository, filters.get(0), includeOptionalDependencies, | |||
options.isEverythingGreedy(), evalFilterTo, considerOnlyStrictDependency, onlyFilteredRequirements) { | |||
|
|||
private static final String TOOLING_SOURCE_IU_ID = PublisherHelper.createDefaultConfigUnitId("source", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is the correct approach also the test failuresindicate that.
|
||
private static final String TOOLING_SOURCE_IU_ID = PublisherHelper.createDefaultConfigUnitId("source", | ||
"tooling"); | ||
|
||
@Override | ||
protected boolean isApplicable(IInstallableUnit iu, IRequirement req) { | ||
if ((includeRequiredBundles || includeRequiredFeatures) && QueryUtil.isGroup(iu) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is actually the place where you want to filter things, this test if a requirement for a IU is applicable and you don't want the new requirement to be considered.
I'm not sure I understand this part.
I think this is the important aspect. We don't want to filter I have moved the condition to |
I must confess I'm not sure |
It has not changed, but before Now they are, and the effect of |
An alternative to the current proposal of looking at |
As said this are not IUs but Requirements ... You can create a so called "context IU" from a map of properties with
for example to check if a requirement is matching that context IU and if yes return false from is applicable if includeAllSources is false. |
I tried this: private static final IInstallableUnit SOURCEC_CONTEXT = InstallableUnit
.contextIU(Map.of("org.eclipse.update.install.source", "true"));
@Override
protected boolean isApplicable(IInstallableUnit iu, IRequirement req) {
if (!includeAllSource) {
IMatchExpression<IInstallableUnit> filter = req.getFilter();
if (filter != null) {
if (filter.isMatch(SOURCEC_CONTEXT)) {
// When dealing with a repository that contains published products, these products
// always include a dependency to 'tooling.source.default', which picks up all sources.
// And since https://github.com/eclipse-equinox/p2/pull/446 the target platform contains
// all the sources. They would be picked up unless we prevent this here.
// See https://github.com/eclipse-tycho/tycho/issues/3522
return false;
}
}
} but it does not work. As outlined in the issue, the problematic IU is // Create a required capability on source providers
IRequirement[] reqs = new IRequirement[] {MetadataFactory.createRequirement(NAMESPACE_ECLIPSE_TYPE, TYPE_ECLIPSE_SOURCE, VersionRange.emptyRange, null, true, true, false)};
cu.setHost(reqs);
Map<String, String> touchpointData = new HashMap<>(); This requirement does not have any filter so the code above will not be able to filter anything here based on the context IU. |
@merks yna you give a hint about the |
One thing that might generally be helpful here is that this is an optional non-greedy requirement:
As far as I understand it, at installation time, an optional non-greedy requirement will not be installed even when it's available, i.e., there must be some other non-optional requirements (in which case the required things must be available), or optional greedy requirement (in which case it's installed when available and quietly ignored when not). Of course the context here is mirroring and not installing. I think in the filtering context here that generally it should be possible to ignore all optional non-greedy requirements. I'm not sure if that should involve yet another configuration option... |
As far as I know "inlcudeAllRequirements" makes everything greedy.... |
Yes, we have I think the intuitive expectation is that And previously this expectation was (usually) met, because the sources typically weren't visible via the target platform in these kind of product-containing repository definitions. So the current proposal of this PR basically ensures that this expectation is met deterministically. |
Instead of looking at the IU's name if (!includeAllSource && req.getMin() == 0 && !req.isGreedy()
&& req instanceof IRequiredCapability capability
&& PublisherHelper.NAMESPACE_ECLIPSE_TYPE.equals(capability.getNamespace())
&& PublisherHelper.TYPE_ECLIPSE_SOURCE.equals(capability.getName())) {
return false;
} WDYT? |
@sratz I suggest you make the change (yes, the test still passes) since I'm a bit incompetent at updating someone else's PR. |
had the same, clearing |
FYI, this test fails for me locally as well: So I'm looking at that... |
In the presence of products, P2 adds a virtual 'tooling.source.default' IU which optionally depends on all sources. If these sources are available in the target platform, this would cause them to be picked up even if assemble-repository was configured with <includeAllDependencies>true<includeAllDependencies> but with <includeAllSources>false</includeAllSources>. This scenario has become much more likely with recent changes to P2 [1]. We do not want includeAllDependencies to imply includeAllSources, so we actively prevent this from happening by ignoring the <required namespace='org.eclipse.equinox.p2.eclipse.type' name='source' range='0.0.0' optional='true' multiple='true' greedy='false'/> requirements if 'includeAllSources' is not specified. Fixes eclipse-tycho#3522. [1] eclipse-equinox/p2#446
The test failure is unrelated and is already fixed in master: tycho/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/P2ResolverTest.java Lines 225 to 226 in d6366ad
The problem is that the test uses a moving target repository so the actual content can and apparently does change:
Please ensure that you rebase your change on master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and is backed by test so I think its ready to go.
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
And a back port too. That's great! Thanks!! |
@sratz many thanks for the fix, as you already have contributed to Tycho for a while I'd like to ask if you want to become a committer I just would need your email address of the eclipse account and can prepare the vote then! |
Thanks for the offer! I pinged you via email. |
In the presence of products, P2 adds a virtual
tooling.source.default
IU which optionally depends on all sources.
If these sources are available in the target platform, this would cause
them to be picked up even if assemble-repository was configured with
but with
This scenario has become much more likely with recent changes to P2 [1].
We do not want includeAllDependencies to imply includeAllSources, so
we actively prevent this from happening by ignoring the
requirements if
includeAllSources
is not specified.Fixes #3522.
[1] eclipse-equinox/p2#446